#include "argparse.h"
#include "shape_v1.h"

#include <iostream>
#include <string>
#include <memory>


class ShapeFactory
{
public:
    static std::unique_ptr<Shape> new_shape(std::string shape_type)
    {
        std::unique_ptr<Shape> shape;

        if(shape_type == "circle")
        {
            shape.reset(new Circle{});
        }
        else if(shape_type == "square")
        {
            shape.reset(new Square{});
        }
        else if(shape_type == "triangle")
        {
            shape.reset(new Triangle{});
        }

        return shape;
    }
};


int main(int argc, char** argv)
{
    argparse::ArgumentParser program("Skill");
    program.add_argument("type").help("shape type");

    try
    {
        program.parse_args(argc, argv);
    }
    catch (const std::runtime_error &err)
    {
        std::cerr << err.what() << std::endl;
        std::cerr << program;
        return 1;
    }

    auto shape_type = program.get<std::string>("type");

    std::unique_ptr<Shape> shape = ShapeFactory::new_shape(shape_type);

    shape->draw();

    return 0;
}